//
//  AddGroupImageViewController.m
//  MyYiJianKangApp
//
//  Created by 张国文 on 16/4/5.
//  Copyright © 2016年 hangzhouyijiyin. All rights reserved.
//

#import "AddGroupImageViewController.h"
#import "CreateGroupFinishViewController.h"

@interface AddGroupImageViewController ()

@end

@implementation AddGroupImageViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    // Do any additional setup after loading the view.
    // navi的修改
    [self changeNavigation];
    // 布局
    [self addMySubview];
}

// navi的修改
- (void)changeNavigation
{
    [self.navigationController.navigationBar setTranslucent:NO];
    self.navigationItem.title = @"上传小组头像";
    UIImageView *leftImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 30, 30)];
    leftImageView.image = [UIImage imageNamed:@"houtui"];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:leftImageView];
    UITapGestureRecognizer *leftTapGes = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(lastPage:)];
    [leftImageView addGestureRecognizer:leftTapGes];
    
    UIBarButtonItem *rightItem = [[UIBarButtonItem alloc] initWithTitle:@"下一步" style:UIBarButtonItemStylePlain target:self action:@selector(nextPage:)];
    rightItem.tintColor = [UIColor whiteColor];
    self.navigationItem.rightBarButtonItem = rightItem;
    
}

#pragma mark - 返回上一页面
- (void)lastPage:(UITapGestureRecognizer *)tapGes
{
    [self.navigationController popViewControllerAnimated:YES];
}

#pragma mark - 下一步
- (void)nextPage:(UIBarButtonItem *)rightItem
{
    CreateGroupFinishViewController *createGroupFinishVC = [[CreateGroupFinishViewController alloc] init];
    [self.navigationController pushViewController:createGroupFinishVC animated:YES];
}

#pragma mark - 布局
- (void)addMySubview
{
    UIImageView *groupTopImageV = [[UIImageView alloc] initWithFrame:CGRectMake(-1 * kAdjustParamater, - 1 * kAdjustParamater, kScreenWidth + 2 * kAdjustParamater, 370 * kAdjustParamater)];
    // groupTopImageV.backgroundColor = [[UIColor redColor] colorWithAlphaComponent:0.3];
    groupTopImageV.image = [UIImage imageNamed:@"groupImage-tianjia"];
    [self.view addSubview:groupTopImageV];
    
    UIButton *selectImageButton = [UIButton buttonWithType:UIButtonTypeSystem];
    selectImageButton.frame = CGRectMake(105 / 2 * kAdjustParamater, groupTopImageV.bottom + 60 * kAdjustParamater, 270 * kAdjustParamater, 40 * kAdjustParamater);
    selectImageButton.layer.cornerRadius = 5 * kAdjustParamater;
    selectImageButton.backgroundColor = kCyanColor;
    [selectImageButton setTitle:@"选择头像" forState:UIControlStateNormal];
    [selectImageButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    selectImageButton.titleLabel.font = [UIFont systemFontOfSize:k18Big];
    [selectImageButton addTarget:self action:@selector(selectImage:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:selectImageButton];
}

#pragma mark - 选则头像
- (void)selectImage:(UIButton *)button
{
    NSLog(@"选择头像");
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
